using Microsoft.Office.Interop.Excel;
using OrderSystem.SystemFramework;
using System;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;

namespace OrderSystem.FormatOutput
{
	public class ExcelOperationOrderForTechnics
	{
		private _Application app;

		private _Workbook workBook;

		private _Worksheet workSheet;

		private Range range;

		private object missing = Missing.Value;

		private string _startupPath = null;

		public ExcelOperationOrderForTechnics(string startupPath)
		{
			this._startupPath = startupPath;
			if (this._startupPath.Substring(this._startupPath.Length - 1, 1) != "\\")
			{
				this._startupPath += "\\";
			}
		}

		private void OpenExcel(string templetFile)
		{
			if (templetFile == null)
			{
				throw new ArgumentException("你指定的参数：templetFile 为空", "templetFile");
			}
			if (!File.Exists(templetFile))
			{
				throw new ArgumentException("你指定的参数：templetFile Excel模板文件不存在", "templetFile");
			}
			this.app = new ApplicationClass();
			this.app.Visible=true;
			this.workBook = this.app.Workbooks.Open(templetFile, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing, this.missing);
			this.workSheet = (_Worksheet)this.workBook.Worksheets[1];
		}

		public void MakeDataToExcel(string templetFile, DataSet dsOrderItem, string orderCode, string companyName, string projectName, string speakForDate, string sDeliveryDate, string linkman, string phone, string address, string sRemark, string sProcessflow, string operatorName, string sSalesperson, string sYaoqiu)
		{
			this.OpenExcel(templetFile);
			string defaultVersionOfOutType = AppSettings.GetDefaultVersionOfOutType("technicsForm");
			if (defaultVersionOfOutType == "1")
			{
				this.MakeDataToExcel_1(dsOrderItem, orderCode, companyName, projectName, speakForDate, sDeliveryDate, linkman, phone, address, sRemark, operatorName, sSalesperson, sYaoqiu, 40, 21);
			}
			if (defaultVersionOfOutType == "3")
			{
				this.MakeDataToExcel_3(dsOrderItem, orderCode, companyName, projectName, speakForDate, sDeliveryDate, linkman, phone, address, sRemark, sProcessflow, operatorName, sSalesperson, 35, 21);
			}
			if (defaultVersionOfOutType == "4")
			{
				this.MakeDataToExcel_4(dsOrderItem, orderCode, companyName, projectName, speakForDate, sDeliveryDate, linkman, phone, address, sRemark, operatorName, sSalesperson, 40, 21);
			}
			if (defaultVersionOfOutType == "5")
			{
				this.MakeDataToExcel_5(dsOrderItem, orderCode, companyName, projectName, speakForDate, sDeliveryDate, linkman, phone, address, sRemark, sProcessflow, operatorName, sSalesperson, 35, 21, sYaoqiu);
			}
			if (defaultVersionOfOutType == "6")
			{
				this.MakeDataToExcel_6(dsOrderItem, orderCode, companyName, projectName, speakForDate, sDeliveryDate, linkman, phone, address, sRemark, sProcessflow, operatorName, sSalesperson, 35, 21, sYaoqiu);
			}
		}

		private void MakeDataToExcel_1(DataSet dsOrderItem, string sOrderCode, string sCompanyName, string sProjectName, string sSpeakForDate, string sDeliveryDate, string sLinkman, string sPhone, string sAddress, string sRemark, string sOperatorName, string sSalesperson, string sYaoqiu, int nRowCountOfPage, int nRowHight)
		{
			int count = dsOrderItem.Tables[0].Rows.Count;
			try
			{
				bool flag = true;
				int num = 1;
				int num2 = 7;
				int num3 = 0;
				decimal d = 0m;
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.range = (Range)this.workSheet.Rows[8, this.missing];
				int i;
				for (i = 1; i < nRowCountOfPage; i++)
				{
					this.range.Insert(-4121, 1);
				}
				this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 7, this.missing];
				for (i = 1; i < nRowCountOfPage; i++)
				{
					Range range = (Range)this.workSheet.Rows[i + 7, this.missing];
					this.range.Copy(range);
				}
				((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.workSheet.Activate();
				this.workSheet.Cells[3, 12]= sOrderCode;
				this.workSheet.Cells[4, 1]= string.Concat(new string[]
				{
					"订货单位:",
					sCompanyName,
					"(",
					sProjectName,
					")    订货时间:",
					sSpeakForDate,
					"  交货日期: ",
					sDeliveryDate
				});
				this.workSheet.Cells[5, 1]= "备    注:" + sRemark;
				this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
				this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
				this.workSheet.Cells[nRowCountOfPage + 7 + 1, 2]= sYaoqiu;
				this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
				num2++;
				this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 2], this.workSheet.Cells[num2, 16]);
				this.range.ClearContents();
				this.range.MergeCells=true;
				this.workSheet.Cells[num2, 1]= "【类型】";
				this.workSheet.Cells[num2, 2]= dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
				for (i = 0; i < count; i++)
				{
					if (flag)
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 12]= sOrderCode;
							this.workSheet.Cells[4, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")    订货时间:",
								sSpeakForDate,
								"  交货日期: ",
								sDeliveryDate
							});
							this.workSheet.Cells[5, 1]= "备    注:" + sRemark;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Cells[nRowCountOfPage + 7 + 1, 2]= sYaoqiu;
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
					}
					decimal d2 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["宽"]);
					decimal d3 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["高"]);
					int num4 = Convert.ToInt32(dsOrderItem.Tables[0].Rows[i]["产品数量"]);
					decimal num5 = d2 * d3 / 1000000m;
					num5 *= num4;
					num3 += num4;
					d += num5;
					if (flag)
					{
						this.workSheet.Cells[num2, 1]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
						string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
						string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
						this.workSheet.Cells[num2, 2]= d2.ToString() + ((text == "") ? "" : ("/" + text));
						this.workSheet.Cells[num2, 3]= d3.ToString() + ((text2 == "") ? "" : ("/" + text2));
						this.workSheet.Cells[num2, 4]= num4.ToString();
						this.workSheet.Cells[num2, 5]= num5.ToString("F3");
						this.workSheet.Cells[num2, 6]= Convert.ToDouble(dsOrderItem.Tables[0].Rows[i]["价格"]).ToString();
						this.workSheet.Cells[num2, 7]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
						this.workSheet.Cells[num2, 8]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString();
						flag = false;
					}
					else
					{
						this.workSheet.Cells[num2, 10]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
						string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
						string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
						this.workSheet.Cells[num2, 11]= d2.ToString() + ((text == "") ? "" : ("/" + text));
						this.workSheet.Cells[num2, 12]= d3.ToString() + ((text2 == "") ? "" : ("/" + text2));
						this.workSheet.Cells[num2, 13]= num4.ToString();
						this.workSheet.Cells[num2, 14]= num5.ToString("F3");
						this.workSheet.Cells[num2, 15]= Convert.ToDouble(dsOrderItem.Tables[0].Rows[i]["价格"]).ToString();
						this.workSheet.Cells[num2, 16]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
						this.workSheet.Cells[num2, 17]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString();
						flag = true;
					}
					string a = dsOrderItem.Tables[0].Rows[i][1].ToString();
					if (i == count - 1)
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 12]= sOrderCode;
							this.workSheet.Cells[4, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")    订货时间:",
								sSpeakForDate,
								"  交货日期: ",
								sDeliveryDate
							});
							this.workSheet.Cells[5, 1]= "备    注:" + sRemark;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Cells[nRowCountOfPage + 7 + 1, 2]= sYaoqiu;
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 3], this.workSheet.Cells[num2, 16]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 2]= " 小计 ";
						this.workSheet.Cells[num2, 3]= "数量：" + num3.ToString() + ";   面积：" + d.ToString("F3");
						num3 = 0;
						d = 0m;
						flag = true;
					}
					else if (a != dsOrderItem.Tables[0].Rows[i + 1][1].ToString())
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 12]= sOrderCode;
							this.workSheet.Cells[4, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")    订货时间:",
								sSpeakForDate,
								"  交货日期: ",
								sDeliveryDate
							});
							this.workSheet.Cells[5, 1]= "备    注:" + sRemark;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Cells[nRowCountOfPage + 7 + 1, 2]= sYaoqiu;
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 3], this.workSheet.Cells[num2, 16]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 2]= " 小计 ";
						this.workSheet.Cells[num2, 3]= "数量：" + num3.ToString() + ";   面积：" + d.ToString("F3");
						num3 = 0;
						d = 0m;
						flag = true;
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 12]= sOrderCode;
							this.workSheet.Cells[4, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")    订货时间:",
								sSpeakForDate,
								"  交货日期: ",
								sDeliveryDate
							});
							this.workSheet.Cells[5, 1]= "备    注:" + sRemark;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Cells[nRowCountOfPage + 7 + 1, 2]= sYaoqiu;
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 2], this.workSheet.Cells[num2, 16]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 1]= "【类型】";
						this.workSheet.Cells[num2, 2]= dsOrderItem.Tables[0].Rows[i + 1]["产品类型"].ToString();
					}
				}
				((Worksheet)this.workBook.Worksheets[1]).Visible=0;
				i = 1;
				while (i <= this.workBook.Sheets.Count)
				{
					if (i > 1)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[i];
						this.workSheet.Cells[nRowCountOfPage + 7 + 2, 15]= string.Concat(new string[]
						{
							"第",
							(i - 1).ToString(),
							"页/共",
							(this.workBook.Sheets.Count - 1).ToString(),
							"页"
						});
						string a2 = ((Range)this.workSheet.Cells[8, 1]).Text.ToString();
						string text3 = ((Range)this.workSheet.Cells[8, 2]).Text.ToString();
						string text4 = ((Range)this.workSheet.Cells[8, 3]).Text.ToString();
						int num4 = 0;
						int num6 = 8;
						if (((Range)this.workSheet.Cells[num6, 1]).Text.ToString() == "【类型】")
						{
							text3 = ((Range)this.workSheet.Cells[num6 + 1, 2]).Text.ToString();
							text4 = ((Range)this.workSheet.Cells[num6 + 1, 3]).Text.ToString();
							num6 = 9;
						}
						if (((Range)this.workSheet.Cells[num6, 1]).Text.ToString() == "·")
						{
							text3 = ((Range)this.workSheet.Cells[10, 2]).Text.ToString();
							text4 = ((Range)this.workSheet.Cells[10, 3]).Text.ToString();
							if (((Range)this.workSheet.Cells[10, 4]).Text.ToString() == "")
							{
								goto IL_2833;
							}
							num6 = 10;
						}
						for (int j = num6; j <= nRowCountOfPage + 7; j++)
						{
							if (((Range)this.workSheet.Cells[j, 2]).Text.ToString() == text3 && ((Range)this.workSheet.Cells[j, 3]).Text.ToString() == text4)
							{
								int num7 = j;
								num4 += Convert.ToInt32(((Range)this.workSheet.Cells[j, 4]).Text.ToString());
								if (num7 == nRowCountOfPage + 7)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 2], this.workSheet.Cells[num7, 2]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 3], this.workSheet.Cells[num7, 3]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text4;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 4], this.workSheet.Cells[num7, 4]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=num4;
								}
							}
							else
							{
								int num7 = j - 1;
								a2 = ((Range)this.workSheet.Cells[j - 1, 1]).Text.ToString();
								if (a2 != "·" && a2 != "【类型】")
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 2], this.workSheet.Cells[num7, 2]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 3], this.workSheet.Cells[num7, 3]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text4;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 4], this.workSheet.Cells[num7, 4]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=num4;
								}
								num6 = j;
								text3 = ((Range)this.workSheet.Cells[j, 2]).Text.ToString();
								text4 = ((Range)this.workSheet.Cells[j, 3]).Text.ToString();
								if (Regex.IsMatch(((Range)this.workSheet.Cells[j, 4]).Text.ToString(), "^[0-9]{1,}$"))
								{
									num4 = Convert.ToInt32(((Range)this.workSheet.Cells[j, 4]).Text.ToString());
								}
								if (text3 == "" && text4 == "")
								{
									break;
								}
							}
						}
						string a3 = ((Range)this.workSheet.Cells[8, 1]).Text.ToString();
						string text5 = ((Range)this.workSheet.Cells[8, 11]).Text.ToString();
						string text6 = ((Range)this.workSheet.Cells[8, 12]).Text.ToString();
						int num8 = 0;
						int num9 = 8;
						if (((Range)this.workSheet.Cells[num9, 1]).Text.ToString() == "【类型】")
						{
							text5 = ((Range)this.workSheet.Cells[num9 + 1, 11]).Text.ToString();
							text6 = ((Range)this.workSheet.Cells[num9 + 1, 12]).Text.ToString();
							num9 = 9;
						}
						if (((Range)this.workSheet.Cells[num9, 1]).Text.ToString() == "·")
						{
							text5 = ((Range)this.workSheet.Cells[10, 11]).Text.ToString();
							text6 = ((Range)this.workSheet.Cells[10, 12]).Text.ToString();
							if (((Range)this.workSheet.Cells[10, 13]).Text.ToString() == "")
							{
								goto IL_2833;
							}
							num9 = 10;
						}
						for (int j = num9; j <= nRowCountOfPage + 7; j++)
						{
							if (((Range)this.workSheet.Cells[j, 11]).Text.ToString() == text5 && ((Range)this.workSheet.Cells[j, 12]).Text.ToString() == text6)
							{
								int num10 = j;
								if (Regex.IsMatch(((Range)this.workSheet.Cells[j, 13]).Text.ToString(), "^[0-9]{1,}$"))
								{
									num8 += Convert.ToInt32(((Range)this.workSheet.Cells[j, 13]).Text.ToString());
								}
								if (num10 == nRowCountOfPage + 7)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 11], this.workSheet.Cells[num10, 11]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text5;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 12], this.workSheet.Cells[num10, 12]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text6;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 13], this.workSheet.Cells[num10, 13]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=num8;
								}
							}
							else
							{
								int num10 = j - 1;
								a3 = ((Range)this.workSheet.Cells[j - 1, 1]).Text.ToString();
								if (a3 != "·" && a3 != "【类型】")
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 11], this.workSheet.Cells[num10, 11]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text5;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 12], this.workSheet.Cells[num10, 12]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text6;
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num9, 13], this.workSheet.Cells[num10, 13]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=num8;
								}
								num9 = j;
								text5 = ((Range)this.workSheet.Cells[j, 11]).Text.ToString();
								text6 = ((Range)this.workSheet.Cells[j, 12]).Text.ToString();
								if (Regex.IsMatch(((Range)this.workSheet.Cells[j, 13]).Text.ToString(), "^[0-9]{1,}$"))
								{
									num8 = Convert.ToInt32(((Range)this.workSheet.Cells[j, 13]).Text.ToString());
								}
								if (text5 == "" && text6 == "" && ((Range)this.workSheet.Cells[j, 2]).Text.ToString() == "" && ((Range)this.workSheet.Cells[j, 3]).Text.ToString() == "")
								{
									break;
								}
								if (((Range)this.workSheet.Cells[j + 1, 11]).Text.ToString() == "" && ((Range)this.workSheet.Cells[j + 1, 12]).Text.ToString() == "" && ((Range)this.workSheet.Cells[j + 1, 2]).Text.ToString() == "" && ((Range)this.workSheet.Cells[j + 1, 3]).Text.ToString() == "")
								{
									break;
								}
							}
							if (text5 == "" && text6 == "" && ((Range)this.workSheet.Cells[j, 2]).Text.ToString() == "" && ((Range)this.workSheet.Cells[j, 3]).Text.ToString() == "")
							{
								break;
							}
						}
					}
					IL_2833:
					i++;
					continue;
					goto IL_2833;
				}
				num2++;
				for (int j = num2; j <= nRowCountOfPage + 7; j++)
				{
					this.range = (Range)this.workSheet.Rows[num2, this.missing];
					this.range.Delete(-4121);
				}
				this.workBook.Save();
			}
			catch (Exception ex)
			{
				this.workBook.Save();
				throw ex;
			}
		}

		private void MakeDataToExcel_3(DataSet dsOrderItem, string sOrderCode, string sCompanyName, string sProjectName, string sSpeakForDate, string sDeliveryDate, string sLinkman, string sPhone, string sAddress, string sRemark, string sProcessflow, string sOperatorName, string sSalesperson, int nRowCountOfPage, int nRowHight)
		{
			int count = dsOrderItem.Tables[0].Rows.Count;
			try
			{
				int num = 1;
				int num2 = 7;
				int num3 = 0;
				decimal d = 0m;
				decimal d2 = 0m;
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.range = (Range)this.workSheet.Rows[8, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					this.range.Insert(-4121, 1);
				}
				this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 7, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					Range range = (Range)this.workSheet.Rows[i + 7, this.missing];
					this.range.Copy(range);
				}
				((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.workSheet.Activate();
				this.workSheet.Cells[3, 1]= string.Concat(new string[]
				{
					"订货单位:",
					sCompanyName,
					"(",
					sProjectName,
					")"
				});
				this.workSheet.Cells[3, 5]= "订 单 号:" + sOrderCode;
				this.workSheet.Cells[4, 1]= "品    种:" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
				this.workSheet.Cells[4, 5]= "订货时间:" + sSpeakForDate + "  交货日期: " + sDeliveryDate;
				this.workSheet.Cells[nRowCountOfPage + 6 + 2, 1]= "工艺流程：" + sProcessflow;
				this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
				this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
				this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
				for (int i = 0; i < count; i++)
				{
					num2++;
					if (num2 > nRowCountOfPage + 7)
					{
						num++;
						((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
						this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
						this.workSheet.Activate();
						this.workSheet.Cells[3, 1]= string.Concat(new string[]
						{
							"订货单位:",
							sCompanyName,
							"(",
							sProjectName,
							")"
						});
						this.workSheet.Cells[3, 5]= "订 单 号:" + sOrderCode;
						this.workSheet.Cells[4, 1]= "品    种:" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
						this.workSheet.Cells[4, 5]= "订货时间:" + sSpeakForDate + "  交货日期: " + sDeliveryDate;
						this.workSheet.Cells[nRowCountOfPage + 6 + 2, 1]= "工艺流程：" + sProcessflow;
						this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
						this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
						this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
						num2 = 8;
					}
					decimal d3 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["宽"]);
					decimal d4 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["高"]);
					int num4 = Convert.ToInt32(dsOrderItem.Tables[0].Rows[i]["产品数量"]);
					decimal d5 = Convert.ToDecimal((d3 * d4 / 1000000m).ToString("F4")) * num4;
					decimal d6 = Convert.ToDecimal(((d3 + d4) * 2m / 1000m).ToString("F4")) * num4;
					num3 += num4;
					d += d5;
					d2 += d6;
					this.workSheet.Cells[num2, 1]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString().Split(new char[]
					{
						'-'
					}).GetValue(1);
					this.workSheet.Cells[num2, 2]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
					string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
					string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
					this.workSheet.Cells[num2, 3]= d3.ToString() + ((text == "") ? "" : ("/" + text));
					this.workSheet.Cells[num2, 4]= d4.ToString() + ((text2 == "") ? "" : ("/" + text2));
					if (dsOrderItem.Tables[0].Rows[i]["异形尺寸"].ToString().Length > 0)
					{
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 3], this.workSheet.Cells[num2, 4]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 3]= dsOrderItem.Tables[0].Rows[i]["异形尺寸"].ToString();
					}
					this.workSheet.Cells[num2, 5]= num4.ToString();
					this.workSheet.Cells[num2, 6]= d5.ToString("F2");
					this.workSheet.Cells[num2, 7]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
					string a = dsOrderItem.Tables[0].Rows[i][1].ToString();
					if (i == count - 1)
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")"
							});
							this.workSheet.Cells[3, 5]= "订 单 号:" + sOrderCode;
							this.workSheet.Cells[4, 1]= "品    种:" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
							this.workSheet.Cells[4, 5]= "订货时间:" + sSpeakForDate + "  交货日期: " + sDeliveryDate;
							this.workSheet.Cells[nRowCountOfPage + 6 + 2, 1]= "工艺流程：" + sProcessflow;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 2], this.workSheet.Cells[num2, 4]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 2]= " 小计 ";
						this.workSheet.Cells[num2, 5]= num3.ToString() + ".";
						this.workSheet.Cells[num2, 6]= d.ToString("F2");
						num3 = 0;
						d = 0m;
					}
					else if (a != dsOrderItem.Tables[0].Rows[i + 1][1].ToString())
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 1]= string.Concat(new string[]
							{
								"订货单位:",
								sCompanyName,
								"(",
								sProjectName,
								")"
							});
							this.workSheet.Cells[3, 5]= "订 单 号:" + sOrderCode;
							this.workSheet.Cells[4, 1]= "品    种:" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
							this.workSheet.Cells[4, 5]= "订货时间:" + sSpeakForDate + "  交货日期: " + sDeliveryDate;
							this.workSheet.Cells[nRowCountOfPage + 6 + 2, 1]= "工艺流程：" + sProcessflow;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 2], this.workSheet.Cells[num2, 4]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 2]= " 小计 ";
						this.workSheet.Cells[num2, 5]= num3.ToString() + ".";
						this.workSheet.Cells[num2, 6]= d.ToString("F2");
						num3 = 0;
						d = 0m;
					}
				}
				((Worksheet)this.workBook.Worksheets[1]).Visible=0;
				for (int i = 1; i <= this.workBook.Sheets.Count; i++)
				{
					if (i > 1)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[i];
						this.workSheet.Cells[nRowCountOfPage + 8 + 1, 8]= string.Concat(new string[]
						{
							"第",
							(i - 1).ToString(),
							"页/共",
							(this.workBook.Sheets.Count - 1).ToString(),
							"页"
						});
						string text3 = ((Range)this.workSheet.Cells[8, 8]).Text.ToString();
						int num5 = 8;
						for (int j = 8; j <= nRowCountOfPage + 7; j++)
						{
							if (((Range)this.workSheet.Cells[j, 8]).Text.ToString() == text3)
							{
								int num6 = j;
								if (num6 == nRowCountOfPage + 7)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num5, 8], this.workSheet.Cells[num6, 8]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range.WrapText=true;
								}
							}
							else
							{
								int num6 = j - 1;
								if (text3 != "·" && text3.IndexOf("★") < 0)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num5, 8], this.workSheet.Cells[num6, 8]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range.WrapText=true;
								}
								num5 = j;
								text3 = ((Range)this.workSheet.Cells[j, 8]).Text.ToString();
								if (text3 == "")
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num5, 1], this.workSheet.Cells[nRowCountOfPage + 7, 8]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									break;
								}
							}
						}
					}
				}
				num2++;
				for (int j = num2; j <= nRowCountOfPage + 7; j++)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Sheets.Count];
					this.range = (Range)this.workSheet.Rows[num2, this.missing];
					this.range.Delete(-4121);
				}
				this.workBook.Save();
			}
			catch (Exception ex)
			{
				this.workBook.Save();
				throw ex;
			}
		}

		private void MakeDataToExcel_4(DataSet dsOrderItem, string sOrderCode, string sCompanyName, string sProjectName, string sSpeakForDate, string sDeliveryDate, string sLinkman, string sPhone, string sAddress, string sRemark, string sOperatorName, string sSalesperson, int nRowCountOfPage, int nRowHight)
		{
			int count = dsOrderItem.Tables[0].Rows.Count;
			try
			{
				int num = 1;
				int num2 = 7;
				int num3 = 0;
				decimal num4 = 0m;
				decimal d = 0m;
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.range = (Range)this.workSheet.Rows[8, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					this.range.Insert(-4121, 1);
				}
				this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 7, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					Range range = (Range)this.workSheet.Rows[i + 7, this.missing];
					this.range.Copy(range);
				}
				((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.workSheet.Activate();
				this.workSheet.Cells[3, 8]= sOrderCode;
				this.workSheet.Cells[3, 2]= sCompanyName + "(" + sProjectName + ")";
				this.workSheet.Cells[4, 2]= sRemark;
				this.workSheet.Cells[4, 8]= sSpeakForDate + "  交货日期: " + sDeliveryDate;
				this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
				this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
				this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
				for (int i = 0; i < count; i++)
				{
					num2++;
					if (num2 > nRowCountOfPage + 7)
					{
						num++;
						((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
						this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
						this.workSheet.Activate();
						this.workSheet.Cells[3, 8]= sOrderCode;
						this.workSheet.Cells[3, 2]= sCompanyName + "(" + sProjectName + ")";
						this.workSheet.Cells[4, 2]= sRemark;
						this.workSheet.Cells[4, 8]= sSpeakForDate + "  交货日期: " + sDeliveryDate;
						this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
						this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
						this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
						num2 = 8;
					}
					decimal d2 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["宽"]);
					decimal d3 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["高"]);
					int num5 = Convert.ToInt32(dsOrderItem.Tables[0].Rows[i]["产品数量"]);
					decimal d4 = Convert.ToDecimal((d2 * d3 / 1000000m).ToString("F4")) * num5;
					decimal d5 = Convert.ToDecimal(((d2 + d3) * 2m / 1000m).ToString("F4")) * num5;
					num3 += num5;
					num4 += d4;
					d += d5;
					this.workSheet.Cells[num2, 1]= dsOrderItem.Tables[0].Rows[i]["产品类型"].ToString();
					this.workSheet.Cells[num2, 3]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
					string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
					string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
					this.workSheet.Cells[num2, 4]= string.Concat(new string[]
					{
						d2.ToString(),
						(text == "") ? "" : ("/" + text),
						"×",
						d3.ToString(),
						(text2 == "") ? "" : ("/" + text2)
					});
					this.workSheet.Cells[num2, 6]= dsOrderItem.Tables[0].Rows[i]["类型单位"].ToString();
					this.workSheet.Cells[num2, 7]= num5.ToString();
					this.workSheet.Cells[num2, 8]= d4.ToString();
					this.workSheet.Cells[num2, 9]= d5.ToString("F4");
					this.workSheet.Cells[num2, 10]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
					this.workSheet.Cells[num2, 11]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString();
					string a = dsOrderItem.Tables[0].Rows[i][1].ToString();
					if (i == count - 1)
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 8]= sOrderCode;
							this.workSheet.Cells[3, 2]= sCompanyName + "(" + sProjectName + ")";
							this.workSheet.Cells[4, 2]= sRemark;
							this.workSheet.Cells[4, 8]= sSpeakForDate + "  交货日期: " + sDeliveryDate;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 3], this.workSheet.Cells[num2, 6]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 3]= " 小计 ";
						this.workSheet.Cells[num2, 7]= num3.ToString() + ".";
						this.workSheet.Cells[num2, 8]= num4;
						this.workSheet.Cells[num2, 9]= d.ToString("F3");
						num3 = 0;
						num4 = 0m;
					}
					else if (a != dsOrderItem.Tables[0].Rows[i + 1][1].ToString())
					{
						num2++;
						if (num2 > nRowCountOfPage + 7)
						{
							num++;
							((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
							this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
							this.workSheet.Activate();
							this.workSheet.Cells[3, 8]= sOrderCode;
							this.workSheet.Cells[3, 2]= sCompanyName + "(" + sProjectName + ")";
							this.workSheet.Cells[4, 2]= sRemark;
							this.workSheet.Cells[4, 8]= sSpeakForDate + "  交货日期: " + sDeliveryDate;
							this.range = (Range)this.workSheet.Cells[nRowCountOfPage + 7 + 2, 1];
							this.range.Value2=this.range.Text.ToString().Replace("?", sOperatorName);
							this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
							num2 = 8;
						}
						this.workSheet.Cells[num2, 1]= "·";
						this.range = this.workSheet.get_Range(this.workSheet.Cells[num2, 3], this.workSheet.Cells[num2, 6]);
						this.range.ClearContents();
						this.range.MergeCells=true;
						this.workSheet.Cells[num2, 3]= " 小计 ";
						this.workSheet.Cells[num2, 7]= num3.ToString() + ".";
						this.workSheet.Cells[num2, 8]= num4;
						this.workSheet.Cells[num2, 9]= d.ToString("F3");
						num3 = 0;
						num4 = 0m;
					}
				}
				((Worksheet)this.workBook.Worksheets[1]).Visible=0;
				for (int i = 1; i <= this.workBook.Sheets.Count; i++)
				{
					if (i > 1)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[i];
						this.workSheet.Cells[nRowCountOfPage + 7 + 1, 10]= string.Concat(new string[]
						{
							"第",
							(i - 1).ToString(),
							"页/共",
							(this.workBook.Sheets.Count - 1).ToString(),
							"页"
						});
						string text3 = ((Range)this.workSheet.Cells[8, 1]).Text.ToString();
						int num6 = 8;
						for (int j = 8; j <= nRowCountOfPage + 7; j++)
						{
							if (((Range)this.workSheet.Cells[j, 1]).Text.ToString() == text3)
							{
								int num7 = j;
								if (num7 == nRowCountOfPage + 7)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 1], this.workSheet.Cells[num7, 2]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range.WrapText=true;
								}
							}
							else
							{
								int num7 = j - 1;
								if (text3 != "·" && text3.IndexOf("★") < 0)
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 1], this.workSheet.Cells[num7, 2]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									this.range.Value2=text3;
									this.range.WrapText=true;
								}
								num6 = j;
								text3 = ((Range)this.workSheet.Cells[j, 1]).Text.ToString();
								if (text3 == "")
								{
									this.range = this.workSheet.get_Range(this.workSheet.Cells[num6, 1], this.workSheet.Cells[nRowCountOfPage + 7, 10]);
									this.range.ClearContents();
									this.range.MergeCells=true;
									break;
								}
							}
						}
					}
				}
				num2++;
				if (this.workBook.Sheets.Count > 1)
				{
					for (int j = 1; j < this.workBook.Sheets.Count; j++)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[j];
						for (int k = nRowCountOfPage + 9; k <= nRowCountOfPage + 12; k++)
						{
							this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 9, this.missing];
							this.range.Delete(-4121);
						}
					}
				}
				for (int j = num2; j <= nRowCountOfPage + 7; j++)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Sheets.Count];
					this.range = (Range)this.workSheet.Rows[num2, this.missing];
					this.range.Delete(-4121);
				}
				this.workBook.Save();
			}
			catch (Exception ex)
			{
				this.workBook.Save();
				throw ex;
			}
		}

		private void MakeDataToExcel_5(DataSet dsOrderItem, string sOrderCode, string sCompanyName, string sProjectName, string sSpeakForDate, string sDeliveryDate, string sLinkman, string sPhone, string sAddress, string sRemark, string sProcessflow, string sOperatorName, string sSalesperson, int nRowCountOfPage, int nRowHight, string sYaoqiu)
		{
			int count = dsOrderItem.Tables[0].Rows.Count;
			try
			{
				int num = 1;
				int num2 = 8;
				int num3 = 0;
				decimal d = 0m;
				decimal d2 = 0m;
				string[] array = sProcessflow.Split(new string[]
				{
					"—＞"
				}, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length > 5)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
					for (int i = 6; i <= array.Length; i++)
					{
						this.range = (Range)this.workSheet.Columns["J:K", this.missing];
						this.range.Insert(-4161, 1);
					}
				}
				for (int i = 0; i < array.Length; i++)
				{
					this.range = this.workSheet.get_Range(this.workSheet.Cells[7, i * 2 + 8], this.workSheet.Cells[8, i * 2 + 8 + 1]);
					this.range.ClearContents();
					this.range.MergeCells=true;
					this.workSheet.Cells[7, i * 2 + 8]= array[i];
					this.range = this.workSheet.get_Range(this.workSheet.Cells[9, i * 2 + 8], this.workSheet.Cells[9, i * 2 + 8 + 1]);
					this.range.ClearContents();
					this.range.MergeCells=true;
				}
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.range = (Range)this.workSheet.Rows[9, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					this.range.Insert(-4121, 1);
				}
				this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 8, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					Range range = (Range)this.workSheet.Rows[i + 8, this.missing];
					this.range.Copy(range);
				}
				((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.workSheet.Activate();
				this.workSheet.Cells[3, 1]= "订单编号：" + sOrderCode;
				this.workSheet.Cells[3, 8]= "成品名称：" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
				this.workSheet.Cells[4, 1]= "客户名称：" + sCompanyName;
				this.workSheet.Cells[4, 8]= "项目名称：" + sProjectName;
				this.workSheet.Cells[5, 1]= "" + sYaoqiu;
				this.workSheet.Cells[nRowCountOfPage + 8 + 5, 1]= string.Concat(new string[]
				{
					"开单人：",
					sOperatorName,
					"           开单时间：",
					sSpeakForDate,
					"           交货时间：",
					sDeliveryDate
				});
				this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
				for (int i = 0; i < count; i++)
				{
					num2++;
					if (num2 > nRowCountOfPage + 8)
					{
						num++;
						((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
						this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
						this.workSheet.Activate();
						this.workSheet.Cells[3, 1]= "订单编号：" + sOrderCode;
						this.workSheet.Cells[3, 8]= "成品名称：" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
						this.workSheet.Cells[4, 1]= "客户名称：" + sCompanyName;
						this.workSheet.Cells[4, 8]= "项目名称：" + sProjectName;
						this.workSheet.Cells[5, 1]= "" + sYaoqiu;
						this.workSheet.Cells[nRowCountOfPage + 8 + 5, 1]= string.Concat(new string[]
						{
							"开单人：",
							sOperatorName,
							"           开单时间：",
							sSpeakForDate,
							"           交货时间：",
							sDeliveryDate
						});
						this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
						num2 = 9;
					}
					decimal d3 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["宽"]);
					decimal d4 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["高"]);
					int num4 = Convert.ToInt32(dsOrderItem.Tables[0].Rows[i]["产品数量"]);
					decimal num5 = d3 * d4 / 1000000m;
					num5 *= num4;
					decimal d5 = Convert.ToDecimal(((d3 + d4) * 2m / 1000m).ToString("F4")) * num4;
					num3 += num4;
					d += num5;
					d2 += d5;
					this.workSheet.Cells[num2, 1]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString().Split(new char[]
					{
						'-'
					}).GetValue(1).ToString();
					this.workSheet.Cells[num2, 2]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
					string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
					string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
					this.workSheet.Cells[num2, 3]= d3.ToString() + ((text == "") ? "" : ("/" + text));
					this.workSheet.Cells[num2, 4]= d4.ToString() + ((text2 == "") ? "" : ("/" + text2));
					this.workSheet.Cells[num2, 5]= num4.ToString();
					this.workSheet.Cells[num2, 6]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
					if (i == count - 1)
					{
						this.workSheet.Cells[nRowCountOfPage + 8 + 2, 2]= string.Concat(new string[]
						{
							"合计：",
							num3.ToString(),
							dsOrderItem.Tables[0].Rows[0]["类型单位"].ToString(),
							" ",
							d.ToString("F2"),
							"平米\r\n边长：",
							d2.ToString("F2"),
							"米"
						});
					}
				}
				((Worksheet)this.workBook.Worksheets[1]).Visible=0;
				for (int i = 1; i <= this.workBook.Sheets.Count; i++)
				{
					if (i > 1)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[i];
						this.workSheet.Cells[2, 8]= string.Concat(new string[]
						{
							"第",
							(i - 1).ToString(),
							"页/共",
							(this.workBook.Sheets.Count - 1).ToString(),
							"页"
						});
					}
				}
				num2++;
				if (this.workBook.Sheets.Count > 1)
				{
					for (int j = 1; j < this.workBook.Sheets.Count; j++)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[j];
						for (int k = nRowCountOfPage + 10; k <= nRowCountOfPage + 12; k++)
						{
							this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 10, this.missing];
							this.range.Delete(-4121);
						}
					}
				}
				for (int j = num2; j <= nRowCountOfPage + 8; j++)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Sheets.Count];
					this.range = (Range)this.workSheet.Rows[num2, this.missing];
					this.range.Delete(-4121);
				}
				this.workBook.Save();
			}
			catch (Exception ex)
			{
				this.workBook.Save();
				throw ex;
			}
		}

		private void MakeDataToExcel_6(DataSet dsOrderItem, string sOrderCode, string sCompanyName, string sProjectName, string sSpeakForDate, string sDeliveryDate, string sLinkman, string sPhone, string sAddress, string sRemark, string sProcessflow, string sOperatorName, string sSalesperson, int nRowCountOfPage, int nRowHight, string sYaoqiu)
		{
			int count = dsOrderItem.Tables[0].Rows.Count;
			try
			{
				int num = 1;
				int num2 = 8;
				int num3 = 0;
				decimal d = 0m;
				decimal d2 = 0m;
				string[] array = sProcessflow.Split(new string[]
				{
					"—＞"
				}, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length > 5)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
					for (int i = 6; i <= array.Length; i++)
					{
						this.range = (Range)this.workSheet.Columns["I:J", this.missing];
						this.range.Insert(-4161, 1);
					}
				}
				for (int i = 0; i < array.Length; i++)
				{
					this.range = this.workSheet.get_Range(this.workSheet.Cells[7, i * 2 + 9], this.workSheet.Cells[8, i * 2 + 9 + 1]);
					this.range.ClearContents();
					this.range.MergeCells=true;
					this.workSheet.Cells[7, i * 2 + 9]= array[i];
					this.range = this.workSheet.get_Range(this.workSheet.Cells[9, i * 2 + 9], this.workSheet.Cells[9, i * 2 + 9 + 1]);
					this.range.ClearContents();
					this.range.MergeCells=true;
				}
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.range = (Range)this.workSheet.Rows[9, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					this.range.Insert(-4121, 1);
				}
				this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 8, this.missing];
				for (int i = 1; i < nRowCountOfPage; i++)
				{
					Range range = (Range)this.workSheet.Rows[i + 8, this.missing];
					this.range.Copy(range);
				}
				((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
				this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
				this.workSheet.Activate();
				this.workSheet.Cells[3, 1]= "订单编号：" + sOrderCode;
				this.workSheet.Cells[3, 7]= "成品名称：" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
				this.workSheet.Cells[4, 1]= "客户名称：" + sCompanyName;
				this.workSheet.Cells[4, 7]= "项目名称：" + sProjectName;
				this.workSheet.Cells[5, 1]= "" + sYaoqiu;
				this.workSheet.Cells[nRowCountOfPage + 8 + 5, 1]= string.Concat(new string[]
				{
					"开单人：",
					sOperatorName,
					"           开单时间：",
					sSpeakForDate,
					"           交货时间：",
					sDeliveryDate
				});
				this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
				for (int i = 0; i < count; i++)
				{
					num2++;
					if (num2 > nRowCountOfPage + 8)
					{
						num++;
						((Worksheet)this.workBook.Worksheets[1]).Copy(this.missing, (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count]);
						this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Worksheets.Count];
						this.workSheet.Activate();
						this.workSheet.Cells[3, 1]= "订单编号：" + sOrderCode;
						this.workSheet.Cells[3, 7]= "成品名称：" + dsOrderItem.Tables[0].Rows[0]["产品类型"].ToString();
						this.workSheet.Cells[4, 1]= "客户名称：" + sCompanyName;
						this.workSheet.Cells[4, 7]= "项目名称：" + sProjectName;
						this.workSheet.Cells[5, 1]= "" + sYaoqiu;
						this.workSheet.Cells[nRowCountOfPage + 8 + 5, 1]= string.Concat(new string[]
						{
							"开单人：",
							sOperatorName,
							"           开单时间：",
							sSpeakForDate,
							"           交货时间：",
							sDeliveryDate
						});
						this.workSheet.Name="页-" + (this.workSheet.Index - 1).ToString();
						num2 = 9;
					}
					decimal d3 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["宽"]);
					decimal d4 = Convert.ToDecimal(dsOrderItem.Tables[0].Rows[i]["高"]);
					int num4 = Convert.ToInt32(dsOrderItem.Tables[0].Rows[i]["产品数量"]);
					decimal num5 = d3 * d4 / 1000000m;
					num5 *= num4;
					decimal d5 = Convert.ToDecimal(((d3 + d4) * 2m / 1000m).ToString("F4")) * num4;
					num3 += num4;
					d += num5;
					d2 += d5;
					this.workSheet.Cells[num2, 1]= dsOrderItem.Tables[0].Rows[i]["产品ID"].ToString().Split(new char[]
					{
						'-'
					}).GetValue(1).ToString();
					this.workSheet.Cells[num2, 2]= dsOrderItem.Tables[0].Rows[i]["产品类型"].ToString();
					this.workSheet.Cells[num2, 3]= dsOrderItem.Tables[0].Rows[i]["产品编号"].ToString();
					string text = dsOrderItem.Tables[0].Rows[i]["宽(短边)"].ToString();
					string text2 = dsOrderItem.Tables[0].Rows[i]["高(短边)"].ToString();
					this.workSheet.Cells[num2, 4]= string.Concat(new string[]
					{
						d3.ToString(),
						(text == "") ? "" : ("/" + text),
						"×",
						d4.ToString(),
						(text2 == "") ? "" : ("/" + text2)
					});
					this.workSheet.Cells[num2, 6]= num4.ToString();
					this.workSheet.Cells[num2, 7]= dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() + ((dsOrderItem.Tables[0].Rows[i]["产品备注"].ToString() != "" && dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString() != "") ? ("/" + dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString()) : dsOrderItem.Tables[0].Rows[i]["产品工艺"].ToString());
					if (i == count - 1)
					{
						this.workSheet.Cells[nRowCountOfPage + 8 + 2, 2]= string.Concat(new string[]
						{
							"合计：",
							num3.ToString(),
							dsOrderItem.Tables[0].Rows[0]["类型单位"].ToString(),
							" ",
							d.ToString("F2"),
							"平米\r\n边长：",
							d2.ToString("F2"),
							"米"
						});
					}
				}
				((Worksheet)this.workBook.Worksheets[1]).Visible=0;
				for (int i = 1; i <= this.workBook.Sheets.Count; i++)
				{
					if (i > 1)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[i];
						this.workSheet.Cells[2, 7]= string.Concat(new string[]
						{
							"第",
							(i - 1).ToString(),
							"页/共",
							(this.workBook.Sheets.Count - 1).ToString(),
							"页"
						});
					}
				}
				num2++;
				if (this.workBook.Sheets.Count > 1)
				{
					for (int j = 1; j < this.workBook.Sheets.Count; j++)
					{
						this.workSheet = (Worksheet)this.workBook.Worksheets[j];
						for (int k = nRowCountOfPage + 10; k <= nRowCountOfPage + 12; k++)
						{
							this.range = (Range)this.workSheet.Rows[nRowCountOfPage + 10, this.missing];
							this.range.Delete(-4121);
						}
					}
				}
				for (int j = num2; j <= nRowCountOfPage + 8; j++)
				{
					this.workSheet = (Worksheet)this.workBook.Worksheets[this.workBook.Sheets.Count];
					this.range = (Range)this.workSheet.Rows[num2, this.missing];
					this.range.Delete(-4121);
				}
				this.workBook.Save();
			}
			catch (Exception ex)
			{
				this.workBook.Save();
				throw ex;
			}
		}
	}
}
